<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Date"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.CommonUtil"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.DateUtil"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.WebUtil"%>
<%@ page import="com.wlcorp.forcazamis.domain.pi.Pidetail"%>
<%@ page import="com.wlcorp.forcazamis.domain.system.Company"%>
<%@ page import="com.wlcorp.forcazamis.domain.pi.PiproductDetail"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.AppConstant"%>

<%
	Pidetail pidetail = (Pidetail) request.getAttribute("pidetail");
	List list = (List) request.getAttribute("piproductDetailList");
	Company company = (Company) request.getAttribute("company");
%>
<%@page import="com.wlcorp.forcazamis.sys.util.DateUtil"%>
<%@page import="com.wlcorp.forcazamis.sys.util.WebUtil"%>
<%@page import="com.wlcorp.forcazamis.domain.system.Company;"%>
<html>
<head>
	<title>PROFORMA INVOICE</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">
	<link href="${pageContext.request.contextPath}/css/print.css" rel=stylesheet>
	<style media="print">
	<!--
	.Noprint{display:none;}
	.PageNext{page-break-after:always;}
	-->
	</style>
	
	<script type="text/javascript">
	function exportPi(piid){
		    parent.location = "${pageContext.request.contextPath}/pi/pidetailManager.do?method=exportPi&piid=" + piid;
		}
	</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
	class=Noprint>
	<tr>
		<td align="right">
			<input type="button" name="Button" value="打印预览" onClick="wb.execwb(7,1)"> 
			<input type="button" name="Button" value=" 打  印 " onClick="window.print();"> 
			<!-- input type="button" name="Button" value=" 打印设置 " onClick="wb.execwb(8,1)"/>--> 
			<input type="button" onClick="javascript:location='#'" value="无旧编号" name="button"> 
			<input type="button" name="Button22" value=" 导  出 " onClick="exportPi('<%=pidetail.getPiid()%>')"> 
			<input type="button" onClick="parent.close()" value="关闭窗口">
		</td>
	</tr>
</table>
<table width="98%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td height="45" valign="top">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="10"></td>
			</tr>
		</table>
		<table width="100%" cellspacing="0" cellpadding="4">
			<tr valign="top">
				<td class="cus_text" width="60%"><font
					face="Arial, Helvetica, sans-serif"><b class="title_middle">FROM: <%=CommonUtil.nullToStr(company.getEfullName())%></b><br>
				<span class="title_middle">ADD: <%=CommonUtil.nullToStr(company.getEaddress())%><br>
              FAX: <%=CommonUtil.nullToStr(company.getFax())%>&nbsp;&nbsp;&nbsp;<%=CommonUtil.nullToStr(company.getElinkman())%></span></font></td>
				<td rowspan="2" class="title_middle"><font face="Arial, Helvetica, sans-serif"><b>DELIVERY DATE:</b><br>
				<FONT style="margin-top: 10; margin-left: 15; margin-right: 10"><%=CommonUtil.nullToStr(pidetail.getOutDate())%></font></font><font face="Arial, Helvetica, sans-serif"><b><br>
				SHIPMENT:</b><br>
				<FONT style="margin-top: 10; margin-left: 15; margin-right: 10"><%=CommonUtil.nullToStr(pidetail.getTransportTypeText())%></font></font><font face="Arial, Helvetica, sans-serif"><b><br>
				PRICE TERM:</b><br>
				<FONT style="margin-top: 10; margin-left: 15; margin-right: 10"><%=CommonUtil.nullToStr(pidetail.getPriceItem())%></font></font><font face="Arial, Helvetica, sans-serif"><b><br>
				PAYMENT:</b><br>
				<FONT style="margin-top: 10; margin-left: 15; margin-right: 10"><%=CommonUtil.nullToStr(pidetail.getBalanceType())%></font></font><font face="Arial, Helvetica, sans-serif"></font></td>
			</tr>
			<tr valign="top">
				<td height="90" class="title_middle" width="60%"><font
					face="Arial, Helvetica, sans-serif"><b>TO: </b> <b><%=CommonUtil.nullToStr(pidetail.getCustomer().getCustomerFullName())%><br>
				</b>ADD: <%=CommonUtil.nullToStr(pidetail.getCustomer().getAddress())%><b><br>
				ATTN: </b> <b><%=CommonUtil.nullToStr(pidetail.getCustomer().getLinkmanName())%></b></font><font face="Arial, Helvetica, sans-serif"><b><br>
				</b></font></td>
			</tr>
		</table>
		</td>
		<td height="45" width="35%">
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td valign="top">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tr align="center">
						<td colspan="2" height="40" valign="top">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td align="center" valign="top"><b><font
									face="Arial, Helvetica, sans-serif" size="6"><nobr>PROFORMA INVOICE</nobr></font></b>
									</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td width="50%" height="25"><nobr><font
							face="Arial, Helvetica, sans-serif" class="text_small"><b>P/I NO: &nbsp;<%=CommonUtil.nullToStr(pidetail.getPiCode())%></b></font></nobr></td>
						<td width="50%" height="19"><nobr>&nbsp;<font
							face="Arial, Helvetica, sans-serif" class="text_small"><b>DATE: &nbsp;<%=DateUtil.toDateString(new Date())%></b></font></nobr></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="0"
					class="tbprint">
					<tr>
						<td width="22%" class="tdprint" height="25"><font
							face="Arial, Helvetica, sans-serif"></font></td>
						<td class="tdprint" width="26%" align="center"><b
							class="text_small"><font face="Arial, Helvetica, sans-serif">Total</font></b></td>
						<td class="tdprint" width="26%" align="center"><b
							class="text_small"><font face="Arial, Helvetica, sans-serif">Re-Order</font></b></td>
						<td class="tdprint" width="26%" align="center"><b
							class="text_small"><font face="Arial, Helvetica, sans-serif">New-Order</font></b></td>
					</tr>
					<tr> 
						<td width="22%" class="tdprint" align="center" height="25"><b
							class="text_small"><font face="Arial, Helvetica, sans-serif">Q'ty(PCS)</font></b></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=pidetail.getTotalQuantity()%></font></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=pidetail.getRePiQuantity()%></font></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=pidetail.getNewPiQuantity()%></font></td>
					</tr>
					<tr>
						<td width="22%" class="tdprint" align="center" height="25"><b
							class="text_small"><font face="Arial, Helvetica, sans-serif"><nobr>Amount(<%=pidetail.getCoinTypeName()%>)</nobr></font></b></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=CommonUtil.format2Scale(pidetail.getTotalSum())%></font></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=CommonUtil.format2Scale(pidetail.getRePiSum())%></font></td>
						<td class="tdprint" width="26%" align="center"><font
							face="Arial, Helvetica, sans-serif" class="text_small"><%=CommonUtil.format2Scale(pidetail.getNewPiSum())%></font></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>

 <br>
 
  <table width="98%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="50%"><font face="Arial, Helvetica, sans-serif"  class="title_middle"><b>ORDER 
              NO:</b> O/N <%=CommonUtil.nullToStr(pidetail.getCustomerOgCode())%></font></td>
      <td align="right" width="50%"><b><font face="Arial, Helvetica, sans-serif"><span class="title_middle">PAGE: 1 / 1</span></font></b>&nbsp;&nbsp;</td>
    </tr>
  </table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0"
	class="tbprint">
	<tr>
		<td class="tdprint" height="25" align="center">NO</td>
		<td class="tdprint" height="25" align="center">STYLE</td>
		<td class="tdprint" align="center">MODEL</td>
		<td class="tdprint" height="25" align="center">OLD MOD</td>
		<td class="tdprint" align="center">SIZE</td>
		<td class="tdprint" height="25" align="center">COL.</td>
		<td class="tdprint" align="center">COL.DESC.</td>
		<td class="tdprint" height="25" align="center">Q'TY</td>
		<td class="tdprint" align="center"><%=CommonUtil.nullToStr(pidetail.getCoinTypeName()) %>/PC</td>
		<td class="tdprint" align="center">AMOUNT</td>
		<td class="tdprint" align="center">REMARKS</td>
	</tr>
	<%
		int totalCount = 0;
		double totalPrice = 0;
		if (null != list && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				PiproductDetail piproductDetail = (PiproductDetail) list
				.get(i);
	%>
	<tr id="<%=piproductDetail.getProductId()%>">
		<td class="tdprint" height="25"><%=i+1%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getCustProdCode())%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getSubSample().getParentSample().getSampleCode())%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getOldCode())%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getSize())%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getCol())%></td>
		<td class="tdprint" height="25">
		<%
		if(null!=piproductDetail.getEcolor()&&!piproductDetail.getEcolor().equals("")){
			out.print(piproductDetail.getEcolor().toString());
		}
		%>
		</td>
		<td class="tdprint" height="25"><%=piproductDetail.getProdCount()%></td>
		<td class="tdprint" height="25">
		<%
			if(piproductDetail.getPrice()!=0.0&&piproductDetail.getPriceAdd()!=0.0){
				out.print(CommonUtil.format2Scale(piproductDetail.getPrice()+piproductDetail.getPriceAdd()));
			}
			if(piproductDetail.getPrice()!=0.0&&piproductDetail.getPriceAdd()==0.0){
				out.print(CommonUtil.format2Scale(piproductDetail.getPrice()));
			}
			if(piproductDetail.getPrice()==0&&piproductDetail.getPriceAdd()!=0.0){
				out.print(CommonUtil.format2Scale(piproductDetail.getPriceAdd()));
			}
		%>
		</td>
		<td class="tdprint" height="25"><%=CommonUtil.format2Scale(piproductDetail.getTotalSum())%></td>
		<td class="tdprint" height="25"><%=CommonUtil.nullToStr(piproductDetail.getRemark())%></td>
	</tr>
	<%
		}
		}
	%>
</table>
<br />
 
<table width="98%" border="0" cellspacing="0" cellpadding="5">
	<tr><td class="title_middle"><b><font
			face="Arial, Helvetica, sans-serif"><%=CommonUtil.nullToStr(pidetail.getMemo())%>
    </tr>
    <tr><td>&nbsp; </td></tr>
	<tr><td>
		<%
		if(null!=pidetail.getCard()){
			if(pidetail.getCard().equals(AppConstant.CARD_USD)){
				out.print(AppConstant.CARD_USD_INFO);
			}
			if(pidetail.getCard().equals(AppConstant.CARD_EUR)){
				out.print(AppConstant.CARD_EUR_INFO);
			}
		}
		%>
		</td>
	</tr>
</table>

<OBJECT id=wb height=0 width=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name="wb"></OBJECT>
</body>
</html>
